import React, { Component } from 'react';
import MyHeader from "../../components/MyHeader";
import Banner from '../../components/Banner';
import Cate from '../../components/nav';
import {index_goodlist} from "../../uilt/api";
class Home extends Component {
    constructor(props){
   super(props);
   this.state={
    indexlist:[]
   }
    }
    componentDidMount(){
        index_goodlist().then((res)=>{
            console.log(res.data,"djfk");
         this.setState({
            indexlist:res.data.list
         })
        })
    }
    render() {
        return (
            <div>
                {/* jsx语法中写js代码要用{}包裹 */}
                {/* 搜索 */}
                <MyHeader></MyHeader>
                {/* 轮播图 */}
                <Banner></Banner>
                {/* 商品分类 */}
                <Cate></Cate>
                {/* 推荐列表 */}
                <div className="recomlist">
                    <div className="retop">
                      <div className="left">
                      <h1>今日值得买</h1>
                        <div className="time">19:99:888</div>
                        <p>后结束</p>
                      </div>
                      <div className="right">MORE</div>
                    </div>
                    <div className="list">
                        {this.state.indexlist.map((item,index)=>{
                            return (
                        <div className="relist" key={index}>
                            <img src={item.pic} alt="" />
                            <div className="name">{item.name}</div>
                        </div>
                            )
                        })
                        }
                    </div>
                </div>
            </div>
        );
    }
}

export default Home;